#include  "testerEmployee.h"
#include  "memoryManager.h"

TesterEmployee::TesterEmployee( const char* desc, const char* lvl) 
    : Employee( desc), level( copyStr( lvl)) { }

TesterEmployee::TesterEmployee( const TesterEmployee& employee)
    : Employee( ), level( copyStr( employee.getLevel( )))
{
    this->setID( employee.getID( ));
    this->setDescription( employee.getDescription( ));
}

void TesterEmployee::setLevel( const char* lvl)
{
    char* tmp = this->copyStr( lvl);
    delete[] this->level;
    this->level = tmp;
}

const char* const TesterEmployee::getLevel( ) const
{
    return this->level;
}

std::ostream& TesterEmployee::print( std::ostream& os) const
{
    return ( os << "Tester ID = "<< this->getID( )
                << ", level = " << this->getLevel( ) 
                << std::endl);
}

TesterEmployee* TesterEmployee::clone( ) const
{
    TesterEmployee *employee = new TesterEmployee( *this);
    return employee;
}

TesterEmployee& TesterEmployee::operator=( const TesterEmployee& employee)
{
    this->setDescription( employee.getDescription( ));
    this->setLevel( employee.getLevel( ));
    this->setID( employee.getID( ));
    return *this;
}

TesterEmployee::~TesterEmployee( )
{
    delete[] level;
}

void* TesterEmployee::operator new( size_t size)
{
    MemoryManager::getInstance( )->allocateForTester( size);
    return ::operator new(  size);
}

void TesterEmployee::operator delete( void* p, size_t size)
{
    MemoryManager::getInstance( )->releaseForTester( size);
    ::operator delete( ( TesterEmployee*)p);
}
